import App from './App'
import {
	createPinia
} from 'pinia'
// #ifdef H5
// import VConsole from 'vconsole'
// const vConsole = new VConsole()
// console.log(vConsole)
// #endif
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
// import VConsole from 'vconsole'
// const vConsole1 = new VConsole()
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'


// 创建事件总线
const eventBus = {
	events: {},
	$on(event, callback) {
		if (!this.events[event]) this.events[event] = []
		this.events[event].push(callback)
	},
	$emit(event, ...args) {
		if (this.events[event]) {
			this.events[event].forEach(callback => callback(...args))
		}
	},
	$off(event, callback) {
		if (this.events[event]) {
			this.events[event] = this.events[event].filter(cb => cb !== callback)
		}
	}
}
export function createApp() {
	const pinia = createPinia()
	const app = createSSRApp(App)
	app.config.globalProperties.$eventBus = eventBus
	app.use(pinia)
	return {
		app,
		pinia
	}
}
// #endif